

from core.himesis import Himesis, HimesisPreConditionPatternLHS
import cPickle as pickle
from uuid import UUID

class HFindTwoApplyElementsWithBackwardLHS(HimesisPreConditionPatternLHS):
    def __init__(self):
        """
        Creates the himesis graph representing the AToM3 model HFindTwoApplyElementsWithBackwardLHS.
        """
        # Flag this instance as compiled now
        self.is_compiled = True
        
        super(HFindTwoApplyElementsWithBackwardLHS, self).__init__(name='HFindTwoApplyElementsWithBackwardLHS', num_nodes=11, edges=[])
        
        # Add the edges
        self.add_edges([(7, 3), (3, 9), (8, 4), (4, 10), (9, 5), (5, 2), (10, 6), (6, 2), (0, 1), (1, 2)])
        # Set the graph attributes
        self["mm__"] = pickle.loads("""(lp1
S'MT_pre__SimpleDSLTransMM'
p2
aS'MoTifRule'
p3
a.""")
        self["MT_constraint__"] = pickle.loads("""Vif PreNode('9')['classtype'] == PreNode('10')['classtype']:\u000a    return True\u000aelse:\u000a    return False\u000a
p1
.""")
        self["name"] = """FindTwoApplyElementsWithBackward"""
        self["GUID__"] = UUID('c3b16ee6-aded-44e9-8353-28ba45cde3c2')
        
        # Set the node attributes
        self.vs[0]["MT_subtypeMatching__"] = False
        self.vs[0]["MT_label__"] = """14"""
        self.vs[0]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[0]["mm__"] = """MT_pre__MatchModel"""
        self.vs[0]["MT_dirty__"] = False
        self.vs[0]["GUID__"] = UUID('bbaacf3f-1cef-4edb-96ae-2b33e97d0e28')
        self.vs[1]["MT_subtypeMatching__"] = False
        self.vs[1]["MT_label__"] = """15"""
        self.vs[1]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[1]["mm__"] = """MT_pre__match_contains"""
        self.vs[1]["MT_dirty__"] = False
        self.vs[1]["GUID__"] = UUID('790cf25b-751f-433a-a383-2b72838aa5f9')
        self.vs[2]["MT_subtypeMatching__"] = True
        self.vs[2]["MT_pre__classtype"] = """
#===============================================================================
# This code is executed when evaluating if a node shall be matched by this rule.
# You can access the value of the current node's attribute value by: attr_value.
# You can access any attribute x of this node by: this['x'].
# If the constraint relies on attribute values from other nodes,
# use the LHS/NAC constraint instead.
# The given constraint must evaluate to a boolean expression.
#===============================================================================

return True
"""
        self.vs[2]["MT_label__"] = """13"""
        self.vs[2]["MT_subtypes__"] = pickle.loads("""(lp1
S'MT_pre__Female_S'
p2
aS'MT_pre__Station_S'
p3
aS'MT_pre__Male_S'
p4
a.""")
        self.vs[2]["mm__"] = """MT_pre__MetaModelElement_S"""
        self.vs[2]["MT_dirty__"] = False
        self.vs[2]["MT_pre__name"] = """
#===============================================================================
# This code is executed when evaluating if a node shall be matched by this rule.
# You can access the value of the current node's attribute value by: attr_value.
# You can access any attribute x of this node by: this['x'].
# If the constraint relies on attribute values from other nodes,
# use the LHS/NAC constraint instead.
# The given constraint must evaluate to a boolean expression.
#===============================================================================

return True
"""
        self.vs[2]["GUID__"] = UUID('c6058315-029c-4032-8108-f87aa3c831c4')
        self.vs[3]["MT_subtypeMatching__"] = False
        self.vs[3]["MT_label__"] = """16"""
        self.vs[3]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[3]["mm__"] = """MT_pre__apply_contains"""
        self.vs[3]["MT_dirty__"] = False
        self.vs[3]["GUID__"] = UUID('5b05a93b-4b58-45ae-9264-dcd537fdcbb6')
        self.vs[4]["MT_subtypeMatching__"] = False
        self.vs[4]["MT_label__"] = """17"""
        self.vs[4]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[4]["mm__"] = """MT_pre__apply_contains"""
        self.vs[4]["MT_dirty__"] = False
        self.vs[4]["GUID__"] = UUID('7c9b73f6-f153-434b-bf60-d7cf60abfa84')
        self.vs[5]["MT_subtypeMatching__"] = False
        self.vs[5]["MT_label__"] = """18"""
        self.vs[5]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[5]["mm__"] = """MT_pre__backward_link"""
        self.vs[5]["MT_dirty__"] = False
        self.vs[5]["GUID__"] = UUID('b33f0e4e-f575-4613-8e44-cf12fabbb327')
        self.vs[6]["MT_subtypeMatching__"] = False
        self.vs[6]["MT_label__"] = """19"""
        self.vs[6]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[6]["mm__"] = """MT_pre__backward_link"""
        self.vs[6]["MT_dirty__"] = False
        self.vs[6]["GUID__"] = UUID('27f03309-217c-41cc-a009-584289d5809b')
        self.vs[7]["MT_subtypeMatching__"] = False
        self.vs[7]["MT_label__"] = """11"""
        self.vs[7]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[7]["mm__"] = """MT_pre__ApplyModel"""
        self.vs[7]["MT_dirty__"] = False
        self.vs[7]["GUID__"] = UUID('83144bc7-e9cb-4884-af10-ed5c4518cbd7')
        self.vs[8]["MT_subtypeMatching__"] = False
        self.vs[8]["MT_label__"] = """12"""
        self.vs[8]["MT_subtypes__"] = pickle.loads("""(lp1
.""")
        self.vs[8]["mm__"] = """MT_pre__ApplyModel"""
        self.vs[8]["MT_dirty__"] = False
        self.vs[8]["GUID__"] = UUID('6e8634ae-5f03-4d54-bac5-eadfdca1cd34')
        self.vs[9]["MT_pivotOut__"] = """element1"""
        self.vs[9]["MT_subtypeMatching__"] = True
        self.vs[9]["MT_pre__classtype"] = """
#===============================================================================
# This code is executed when evaluating if a node shall be matched by this rule.
# You can access the value of the current node's attribute value by: attr_value.
# You can access any attribute x of this node by: this['x'].
# If the constraint relies on attribute values from other nodes,
# use the LHS/NAC constraint instead.
# The given constraint must evaluate to a boolean expression.
#===============================================================================

return True
"""
        self.vs[9]["MT_label__"] = """9"""
        self.vs[9]["MT_subtypes__"] = pickle.loads("""(lp1
S'MT_pre__Female_T'
p2
aS'MT_pre__Station_T'
p3
aS'MT_pre__Male_T'
p4
a.""")
        self.vs[9]["mm__"] = """MT_pre__MetaModelElement_T"""
        self.vs[9]["MT_dirty__"] = False
        self.vs[9]["MT_pre__name"] = """
#===============================================================================
# This code is executed when evaluating if a node shall be matched by this rule.
# You can access the value of the current node's attribute value by: attr_value.
# You can access any attribute x of this node by: this['x'].
# If the constraint relies on attribute values from other nodes,
# use the LHS/NAC constraint instead.
# The given constraint must evaluate to a boolean expression.
#===============================================================================

return True
"""
        self.vs[9]["GUID__"] = UUID('deca9018-040d-4ca6-80de-adce8079e4bc')
        self.vs[10]["MT_pivotOut__"] = """element2"""
        self.vs[10]["MT_subtypeMatching__"] = True
        self.vs[10]["MT_pre__classtype"] = """
#===============================================================================
# This code is executed when evaluating if a node shall be matched by this rule.
# You can access the value of the current node's attribute value by: attr_value.
# You can access any attribute x of this node by: this['x'].
# If the constraint relies on attribute values from other nodes,
# use the LHS/NAC constraint instead.
# The given constraint must evaluate to a boolean expression.
#===============================================================================

return True
"""
        self.vs[10]["MT_label__"] = """10"""
        self.vs[10]["MT_subtypes__"] = pickle.loads("""(lp1
S'MT_pre__Female_T'
p2
aS'MT_pre__Station_T'
p3
aS'MT_pre__Male_T'
p4
a.""")
        self.vs[10]["mm__"] = """MT_pre__MetaModelElement_T"""
        self.vs[10]["MT_dirty__"] = False
        self.vs[10]["MT_pre__name"] = """
#===============================================================================
# This code is executed when evaluating if a node shall be matched by this rule.
# You can access the value of the current node's attribute value by: attr_value.
# You can access any attribute x of this node by: this['x'].
# If the constraint relies on attribute values from other nodes,
# use the LHS/NAC constraint instead.
# The given constraint must evaluate to a boolean expression.
#===============================================================================

return True
"""
        self.vs[10]["GUID__"] = UUID('567bf5fb-dd43-48a2-8b6c-9afb54867493')

    def eval_classtype9(self, attr_value, this):
        
        #===============================================================================
        # This code is executed when evaluating if a node shall be matched by this rule.
        # You can access the value of the current node's attribute value by: attr_value.
        # You can access any attribute x of this node by: this['x'].
        # If the constraint relies on attribute values from other nodes,
        # use the LHS/NAC constraint instead.
        # The given constraint must evaluate to a boolean expression.
        #===============================================================================
        
        return True


    def eval_name9(self, attr_value, this):
        
        #===============================================================================
        # This code is executed when evaluating if a node shall be matched by this rule.
        # You can access the value of the current node's attribute value by: attr_value.
        # You can access any attribute x of this node by: this['x'].
        # If the constraint relies on attribute values from other nodes,
        # use the LHS/NAC constraint instead.
        # The given constraint must evaluate to a boolean expression.
        #===============================================================================
        
        return True


    def eval_classtype10(self, attr_value, this):
        
        #===============================================================================
        # This code is executed when evaluating if a node shall be matched by this rule.
        # You can access the value of the current node's attribute value by: attr_value.
        # You can access any attribute x of this node by: this['x'].
        # If the constraint relies on attribute values from other nodes,
        # use the LHS/NAC constraint instead.
        # The given constraint must evaluate to a boolean expression.
        #===============================================================================
        
        return True


    def eval_name10(self, attr_value, this):
        
        #===============================================================================
        # This code is executed when evaluating if a node shall be matched by this rule.
        # You can access the value of the current node's attribute value by: attr_value.
        # You can access any attribute x of this node by: this['x'].
        # If the constraint relies on attribute values from other nodes,
        # use the LHS/NAC constraint instead.
        # The given constraint must evaluate to a boolean expression.
        #===============================================================================
        
        return True


    def eval_classtype13(self, attr_value, this):
        
        #===============================================================================
        # This code is executed when evaluating if a node shall be matched by this rule.
        # You can access the value of the current node's attribute value by: attr_value.
        # You can access any attribute x of this node by: this['x'].
        # If the constraint relies on attribute values from other nodes,
        # use the LHS/NAC constraint instead.
        # The given constraint must evaluate to a boolean expression.
        #===============================================================================
        
        return True


    def eval_name13(self, attr_value, this):
        
        #===============================================================================
        # This code is executed when evaluating if a node shall be matched by this rule.
        # You can access the value of the current node's attribute value by: attr_value.
        # You can access any attribute x of this node by: this['x'].
        # If the constraint relies on attribute values from other nodes,
        # use the LHS/NAC constraint instead.
        # The given constraint must evaluate to a boolean expression.
        #===============================================================================
        
        return True


    def constraint(self, PreNode, graph):
        """
            Executable constraint code. 
            @param PreNode: Function taking an integer as parameter
                            and returns the node corresponding to that label.
        """
        if PreNode('9')['classtype'] == PreNode('10')['classtype']:
            return True
        else:
            return False

